
import java.util.ArrayList;
import java.util.*;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Andrea
 */
public class Algorithms {
    
    public boolean getRandomResult(double probability){
        Random generator = new Random(System.nanoTime());
        double r = generator.nextDouble();
        if (r <= probability){
            return true;
        } else{
            return false;
        }
    }
    
    public void Resource_Algorithm(){
        ArrayList vArrayList = new ArrayList();
        XMLDTO vXMLDTO = new XMLDTO(true);
        int qRow = 0;
        int qColumn = 0;
        DatabaseHelper vDatabaseHelper = new DatabaseHelper();
        vArrayList = vDatabaseHelper.returnResourceDTO(vXMLDTO); // get all resource entries which have no resources
        for(int x = 0; x < vArrayList.size(); x++){
            if (getRandomResult(0.5)){//50% chance to generate the resource
                qRow = ((ResourceDTO) vArrayList.get(x)).getGridRow();
                qColumn = ((ResourceDTO) vArrayList.get(x)).getGridColumn();
                vDatabaseHelper.reactivate_resource(qRow, qColumn);
                //update the overlay (set block at qRow, qColumn, 10000
            }
        }   
    }
    
    public void Zombie_Apocalypse(){
        //zombie algorithm
    }
}